package SomeClass;
/**
 * 定义一个简单的包装类
 */
public class MyInteger {
    private int value;
    private static MyInteger[] cache;
    public static final int low = -128 ;
    public static final int high = 127 ;

    static {
        //[-128,127]
        for (int i = low; i <= high; i++) {
            //-128,0;-127,2;-126,3
            cache[i + 128] = MyInteger.valueOf(i);
        }

    }

    public static MyInteger valueOf(int i) {
        if (i >= low && i<= high){
            return cache[i+128];
        }
        return new MyInteger(i);

    }
    private MyInteger(int i) {
        this.value = i;
    }

    public static void main(String[] args) {
        MyInteger m = MyInteger.valueOf(300);
    }

}
